<h1 id="json-array">JSON Array</h1>
<p>Quick的数组的功能与js的基本一致  </p>
<h3 id="初始化">初始化</h3>
<pre><code class="hljs language-javascript">arr1 = []

arr2 = [<span class="hljs-number">1</span>, <span class="hljs-literal">false</span>, <span class="hljs-string">&quot;NT&quot;</span>]

str = <span class="hljs-string">&quot;thor&quot;</span>
arr3 = [str, <span class="hljs-literal">true</span>]
</code></pre>
<h3 id="查看数组长度">查看数组长度</h3>
<pre><code class="hljs language-javascript">arr = [<span class="hljs-number">1</span>, <span class="hljs-literal">false</span>, <span class="hljs-string">&quot;NT&quot;</span>]
<span class="hljs-title function_">println</span>(arr.<span class="hljs-title function_">size</span>()) <span class="hljs-comment">// 3</span>
</code></pre>
<h3 id="获取数组元素">获取数组元素</h3>
<pre><code class="hljs language-javascript">arr = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-string">&quot;a&quot;</span>, <span class="hljs-string">&quot;b&quot;</span>, <span class="hljs-string">&quot;c&quot;</span>]
<span class="hljs-title function_">println</span>(arr[<span class="hljs-number">1</span>]) <span class="hljs-comment">// 2</span>
<span class="hljs-title function_">println</span>(arr[<span class="hljs-number">3</span>]) <span class="hljs-comment">// &quot;a&quot;</span>
</code></pre>
<h3 id="数组截取">数组截取</h3>
<pre><code class="hljs language-javascript">arr = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-string">&quot;a&quot;</span>, <span class="hljs-string">&quot;b&quot;</span>, <span class="hljs-string">&quot;c&quot;</span>]
<span class="hljs-title function_">println</span>(arr[<span class="hljs-number">4</span>:]) <span class="hljs-comment">// [&quot;b&quot;, &quot;c&quot;]</span>
<span class="hljs-title function_">println</span>(arr[:<span class="hljs-number">2</span>]) <span class="hljs-comment">// [1, 2]</span>
<span class="hljs-title function_">println</span>(arr[<span class="hljs-number">3</span>:<span class="hljs-number">5</span>]) <span class="hljs-comment">// [&quot;a&quot;, &quot;b&quot;]</span>
</code></pre>
<h3 id="数组元素赋值">数组元素赋值</h3>
<pre><code class="hljs language-javascript">arr = [<span class="hljs-number">1</span>, <span class="hljs-literal">false</span>, <span class="hljs-string">&quot;NT&quot;</span>]
arr[<span class="hljs-number">1</span>] = <span class="hljs-string">&quot;change&quot;</span>
<span class="hljs-title function_">println</span>(arr) <span class="hljs-comment">// [1, &quot;change&quot;, &quot;NT&quot;]</span>
</code></pre>
<h3 id="添加元素">添加元素</h3>
<pre><code class="hljs language-javascript">arr = [<span class="hljs-number">1</span>, <span class="hljs-literal">false</span>, <span class="hljs-string">&quot;NT&quot;</span>]
arr.<span class="hljs-title function_">add</span>(<span class="hljs-number">998</span>)
arr.<span class="hljs-title function_">add</span>(<span class="hljs-number">3.14</span>, <span class="hljs-string">&quot;jerry&quot;</span>)
<span class="hljs-title function_">println</span>(arr) <span class="hljs-comment">// [1, false, &quot;NT&quot;, 998, 3.14, &quot;jerry&quot;]</span>
</code></pre>
<h3 id="删除元素">删除元素</h3>
<pre><code class="hljs language-javascript">arr = [<span class="hljs-number">1</span>, <span class="hljs-literal">false</span>, <span class="hljs-string">&quot;NT&quot;</span>]
arr.<span class="hljs-title function_">remove</span>(<span class="hljs-number">1</span>)
<span class="hljs-title function_">println</span>(arr) <span class="hljs-comment">// [1, &quot;NT&quot;]</span>
</code></pre>
<h3 id="根据指定字符，将数组所有元素拼接成字符串">根据指定字符，将数组所有元素拼接成字符串</h3>
<pre><code class="hljs language-javascript">arr = [<span class="hljs-number">1</span>, <span class="hljs-literal">false</span>, <span class="hljs-string">&quot;D&quot;</span>]
<span class="hljs-title function_">println</span>( arr.<span class="hljs-title function_">join</span>(<span class="hljs-string">&quot;,&quot;</span>)) <span class="hljs-comment">// 1,false,D</span>
<span class="hljs-title function_">println</span>( arr.<span class="hljs-title function_">join</span>(<span class="hljs-string">&quot;, &quot;</span>)) <span class="hljs-comment">// 1, false, D</span>
<span class="hljs-title function_">println</span>( arr.<span class="hljs-title function_">join</span>(<span class="hljs-string">&quot;#&quot;</span>)) <span class="hljs-comment">// 1#false#D</span>
</code></pre>
<h3 id="for遍历">for遍历</h3>
<pre><code class="hljs language-javascript">arr = [<span class="hljs-number">1</span>, <span class="hljs-literal">false</span>, <span class="hljs-string">&quot;NT&quot;</span>]
<span class="hljs-keyword">for</span> i=<span class="hljs-number">0</span>; i&lt;arr.<span class="hljs-title function_">size</span>(); i++ {
    <span class="hljs-title function_">println</span>(i, arr[i])
}
</code></pre>
<p>输出</p>
<pre><code>0 1
1 false
2 NT
</code></pre>
<h3 id="foreach遍历">foreach遍历</h3>
<pre><code class="hljs language-javascript">arr = [<span class="hljs-number">998</span>, <span class="hljs-literal">true</span>, <span class="hljs-string">&quot;DONE&quot;</span>]
foreach i, item : arr {
    <span class="hljs-title function_">println</span>(i, item)
}
</code></pre>
<p>输出</p>
<pre><code>0 998
1 true
2 DONE
</code></pre>
<h3 id="数组方法">数组方法</h3>
<table>
<thead>
<tr>
<th>方法</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>size()</td>
<td>数组元素数量</td>
</tr>
<tr>
<td>add(elem...)</td>
<td>添加元素,允许同时添加多个</td>
</tr>
<tr>
<td>remove(index)</td>
<td>移除元素</td>
</tr>
<tr>
<td>join(seperator)</td>
<td>根据指定字符，将数组所有元素拼接成字符串</td>
</tr>
</tbody></table>
